/**
 * 
 */
package reco.db.validation;

import static org.apache.commons.lang.StringUtils.isBlank;

import org.apache.commons.validator.EmailValidator;

import reco.db.Constraint;

/**
 * @author juanjo
 */
public class EmailConstraint extends Constraint<String> {

    private static final EmailValidator VALIDATOR = EmailValidator.getInstance();

    /**
     * @param constraintField
     * @param constraintName
     * @param constraintMessage
     */
    public EmailConstraint() {
        super("email", "isNotEmail");
    }

    @Override
    public boolean validate(String value) {
        if (isBlank(value)) {
            return true;
        }
        return VALIDATOR.isValid(value);
    }

    @Override
    public Object[] getErrorArguments() {
        return null;
    }

}
